<template>
    
    <table border="1">
        <tr>
            <td>会员名称</td>
            <td>
                <input type="text" placeholder="请输入会员名称" v-model="info.Name">
            </td>
        </tr>
        <tr>
            <td>会员电话</td>
            <td>
                <input type="text" placeholder="请输入电话" v-model="info.Phone">

            </td>
        </tr>

        <tr>
            <td>金额</td>
            <td>
                <input type="text" placeholder="请输入金额" v-model="info.Maney">

            </td>
        </tr>

        <tr>
            <td>性别</td>
            <td>
                <input type="radio" v-model="info.Sex"  :value="true">男
                <input type="radio" v-model="info.Sex"  :value="false">女
            </td>
        </tr>

        <tr>
            <td>积分</td>
            <td>
                <input type="text" placeholder="请输入会员名称" v-model="info.Jifen">

            </td>
        </tr>

        <tr>
            <td>会员级别</td>
            <td>
                <select v-model="info.R_Id">
                    <option :value="0">请选择</option>
                    <option  v-for="init in xiala" :value="init.R_Id">{{ init.R_Name }}</option>
                </select>
            </td>
        </tr>

        <tr>
            <td></td>
            <td>
                <input type="button" value="添加" @click="saveadd">
            </td>
        </tr>


    </table>
</template>

<script setup lang="ts">
import {onMounted,ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';
const info=ref({
    Bh:"1234",
    Name:"",
    Phone:"",
    Date:"2024-11-18T13:02:33.748Z",
    Maney:"",
    Sex:true,
    Jifen:"",
    IsDel:true,
    R_Id:0
})


// const info=ref({
   
//     Bh: "string",
//   Name: "string",
//   Phone: "string",
//   Date:"2024/11/18 20:39:35",
//   Maney: 0,
//   Sex: true,
//   Jifen: 0,
 
//   R_Id: 0,
// })


const xiala=ref([{
    "R_Id": 0,
    "R_Name": ""
}])
onMounted(()=>{
    jibie()
})


const jibie=()=>{

    axios.get("https://localhost:7122/api/Member/GetRank")
    .then(res=>{
        xiala.value=res.data
    })
}



const saveadd=()=>{
    console.log(info.value)
    // if(info.value.Name==""){
    //     alert("不能为空");
    //     return;
    // }
    // if(info.value.Phone==""){
    //     alert("会员电话");
    //     return;
    // }

    axios.post("https://localhost:7122/api/Member/AddMemberInfo",info.value)
    .then(res=>{
        if(res.data>0){
            alert("添加成功");
            rout.push("/ShowMemberInfo");
        }else{
            alert("添加失败");
        }
    })
}
</script>

<style scoped>

</style>